package com.bolehui.web;

import com.bolehui.base.enums.UserTypeEnum;
import com.bolehui.base.result.Result;
import com.bolehui.domain.po.Conversation;
import com.bolehui.service.ConversationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chendongjie     email:chendongjie@gz.iscas.ac.cn
 * @version 1.0
 * @ClassName ConversationController
 * @Description
 * @createTime 2025/3/15-13:46
 * Copyright (C) 2021-2022 CASEEDER, All Rights Reserved.
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 */
@RestController
@RequestMapping("/conversations")
public class ConversationController {


    @Autowired
    private ConversationService conversationService;

    /**
     * 创建会话
     *
     * @param employerId 招聘者ID
     * @param candidateId 求职者ID
     * @return 创建的会话对象
     */
    @RequestMapping(params = "action=save")
    public Result createConversation(
            @RequestParam Long employerId,
            @RequestParam Long candidateId,
            String jobName
    ) {
        return conversationService.createConversation(employerId, candidateId, jobName);
    }

    /**
     * 查询会话
     * @param id
     * @param userType
     * @return
     */
    @RequestMapping(params = "action=list")
    public Result listConversation(
            @RequestParam Long id,
            @RequestParam UserTypeEnum userType
            ){
        return conversationService.listConversation(id, userType);
    }

    @RequestMapping(params = "action=listByCompanyId")
    public Result listByCompanyIdWithPage(Long companyId, Integer pageNum, Integer pageSize){
        return conversationService.listByCompanyId(companyId, pageNum, pageSize);
    }

    @RequestMapping(params = "action=doDelivery")
    public Result doDelivery(Long id, String deliveryStatus){
        return conversationService.doDeliveryProgress(id, deliveryStatus);
    }

    @RequestMapping(params = "action=statisticsResume")
    public Result statisticsResume(){
        return Result.success(conversationService.getResumeStatsLastSixMonths());
    }

    @RequestMapping(params = "action=statisticsPreview")
    public Result statisticsPreview(){
        return Result.success(conversationService.getPreviewStatsLastSixMonths());
    }
}
